/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.biblioteca8a.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.dsw2.biblioteca8a.modelo.Libro;
import mx.itschapala.dsw2.biblioteca8a.modelo.Libro;

@Stateless
public class LibroDao extends AbstractDao<Libro> implements LibroDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8A-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LibroDao() {
        super(Libro.class);
    }
    
     public Libro find(Object id) {
        return new Libro();
    }
     public boolean findDuplicity(Libro book) {
    Query q= em.createNamedQuery("Libro.findDuplicity");
    q.setParameter("clave", book.getClave());
    
    return !q.getResultList().isEmpty();
        }
}
